//save the old point of the mouse for deleting when it moves
var oldPt = [0,0,6,6];

//calculates where to draw the orthomap pointer based on the proj map coordinates
function drawProjCursor(p)
{
	var canvasProj = document.getElementById("canvasProjDraw");
	var ctx = canvasProj.getContext("2d");
	
	ctx.clearRect(oldPt[0],oldPt[1],oldPt[2],oldPt[3]);
	ctx.strokeStyle = 'blue';
	ctx.lineStyle = "rgb(200,0,0)";	 		 		
	ctx.beginPath();

	ctx.arc(p[0],p[1] , 3, 0, Math.PI*2, true); 
	ctx.stroke();
	oldPt[0] = p[0] - 4;
	oldPt[1] = p[1] - 4;// - projRect[1]*2;
	oldPt[2] = p[0] + 4;
	oldPt[3] = p[1] + 4;// - projRect[1]*2;
	
	var ang = Math.PI*2*p[0]/PROJ_CANVAS_WIDTH;

	var canvasOrtho = document.getElementById("canvasOrthoDraw");
	var ctxOrtho = canvasOrtho.getContext("2d");
	var inverseY = inverseMapY(p[1],1);
	ctxOrtho.clearRect(0,0,200,200);
	ctxOrtho.strokeStyle = 'blue';
	ctxOrtho.lineStyle = "rgb(200,0,0)";	 		 		
	ctxOrtho.beginPath();
	ctxOrtho.arc(100,100, 3, 0, Math.PI*2, true); 
	ctxOrtho.moveTo(100,100);
	
	var endX =  ORTHO_CANVAS_DIAMETER/2 + Math.cos(ang - Math.PI/6)*inverseY;
	var endY =  ORTHO_CANVAS_DIAMETER/2 + Math.sin(ang - Math.PI/6)*inverseY;
	
	var endX2 =  ORTHO_CANVAS_DIAMETER/2 + Math.cos(ang + Math.PI/6)*inverseY;
	var endY2 =  ORTHO_CANVAS_DIAMETER/2 + Math.sin(ang + Math.PI/6)*inverseY;
	ctxOrtho.lineTo(endX,endY);
	ctxOrtho.lineTo(endX2,endY2);
	ctxOrtho.lineTo(ORTHO_CANVAS_DIAMETER/2,ORTHO_CANVAS_DIAMETER/2);
		
	ctxOrtho.stroke();
}

//my way of debuggin..
function traceOutput(str)
{
	//document.getElementById("tracer").innerHTML = "no mouse";
		var strIs = document.getElementById('tracer3').innerHTML;
		document.getElementById('tracer3').innerHTML = strIs + "<p>" + str + "</p>"; 
	//canvasProj.setIn
}

//this function will toggle visible layers based on tags.
function toggleLayer(val)
{
	traceOutput("sel " + val + "  :  " + rootXML.getElementsByTagName("node").length);
}

function updateProjMouseCoord()
{
	//if(mouseStatus == PROJ_MOUSE)
	//{
		drawProjCursor( mouseCoord )
	//}	
}
  
function openNewWindow(link) 
{
popupWin = window.open(link,
"open_window","menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=640, height=480, left=0, top=0")
 } 
  
  function drawViewFrame()
  {
	  
	  var canvasProj = document.getElementById("canvasProjDraw");
	  var ctx = canvasProj.getContext("2d");
		
	  
  }